package com.scholarone.s1exporttool.common;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;

import com.scholarone.s1exporttool.domain.Resource;
import com.scholarone.s1exporttool.service.ExportService;

public class DataSourceNameTests extends
		AbstractDependencyInjectionSpringContextTests {

	@Autowired
	private ExportService exportService;

	public void testDataSourceRouting() {
		for (int i = 0; i < DataSource.values().length; i++) {
			System.out.println("DataSource["+i+"] "+DataSource.values()[i]);
			System.out.println("Value["+i+"] "+DataSource.values()[i].getCode());
		}
		DataSourceContextHolder.setDataSource(DataSource.PROD1);
		List<Resource> prodResources = exportService.getResources();
		assertEquals(5, prodResources.size());
		System.out.println("prod items: " + prodResources);

		DataSourceContextHolder.setDataSource(DataSource.IMPL1);
		List<Resource> implResources = exportService.getResources();
		assertEquals(5, implResources.size());
		System.out.println("impl items: " + implResources);

		DataSourceContextHolder.setDataSource(DataSource.STAGE1);
		List<Resource> stageResources = exportService.getResources();
		assertEquals(5, stageResources.size());
		System.out.println("stage items: " + stageResources);

		DataSourceContextHolder.setDataSource(DataSource.SNAP1);
		List<Resource> snapResources = exportService.getResources();
		assertEquals(5, snapResources.size());
		System.out.println("snap items: " + snapResources);
	}

	protected String[] getConfigLocations() {
		// System.out.println(System.);
		return new String[] { "applicationcontext.xml" };
	}
}
